package com.andong.controller;

import com.andong.annotations.AccessControl;
import com.andong.domain.entity.Comment;
import com.andong.domain.pojo.Result;
import com.andong.domain.vo.CommentVO;
import com.andong.service.CommentService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

import java.util.List;

import static com.andong.utils.SystemConstant.*;

/**
 * 教练评论表(Comment)表控制层
 *
 * @author makejava
 * @since 2024-01-13 14:37:31
 */
@RestController
@RequestMapping("/comment")
public class    CommentController {
    /**
     * 服务对象
     */
    @Resource
    private CommentService commentService;

    @PostMapping()
    @AccessControl(roles = STUDENT)
    public Result insert(@RequestBody Comment comment) {
        return commentService.insert(comment);
    }

    @DeleteMapping("/{id}")
    @AccessControl(roles = STUDENT)
    public Result delete(@PathVariable Long id) {
        return commentService.deleteById(id);
    }

    @GetMapping("/{id}")
    @AccessControl(roles = {STUDENT, COACH, ADMIN, SUPER_ADMIN})
    public Result list(@PathVariable Long id) {
        List<CommentVO> commentVOList = commentService.queryList(id);
        return Result.success(commentVOList);
    }
}

